<?php $this->headStyle()->captureStart()?>
    #content td { padding:5px}
    #content table { border:1px #aaa solid; padding:5px; width:100%}
    #content th {font-weight:bold;}
    #content .page a {padding:2px;}
<?php $this->headStyle()->captureEnd()?>
<form method="get" name="message_form">
    <a href="<?php echo $this->geturl('add','message', null, 'admin1')?>">Add</a>
    Keyword : <input type="text" name="message" id="search" value="<?php if (!empty($_GET['message'])) { echo $_GET['message']; }?>"/>
    <input type="submit" name="search_btn" id="search_btn" value="Search"/>
    <?php if (!empty($_GET['message'])) { ?>
        <a href="<?php echo $this->geturl('list','message', null, 'admin1')?>">View All</a>
    <?php } ?>
    <a href="<?php echo $this->geturl('spam','message', null, 'admin1')?>">Spam Messages</a>
</form>
    
<table border="1" id="listings">
<?php
    if (!isset($_GET['message'])) {$_GET['message'] = '';}
    $get = $_GET; unset($get['page']);
    $pagination = $this->pagination($this->listing_number, $this->page, 20, 4, $this->geturl('list', 'message', null, 'admin1', $get));
?>
<?php if($this->listing_number == 0):?>
	No message are defined
<?php else:?>
    <tr>
        <th>
            Subject
        </th>
        <th>
            From
        </th>
        <th>
            To
        </th>
        <th>
            Status
        </th>
        <th>
            Creation date
        </th>
   </tr>
    <?php foreach ($this->list as $item):?>
        <tr>
            <td>
                <a href="<?php echo $this->geturl('display', 'message', null, 'admin1', array('id'=> $item->_id))?>" target="_blank">
                    <?php echo $item->su; ?>
                </a>
            </td>
            <td>
                <?php
                if (is_array($item->fo)) {
                    echo $item->fo['email'];
                }
                else {
                    echo $item->fo;
                }
                ?>
            </td>
             <td>
                <?php echo $item->to; ?>
            </td>
            <td>
                <?php echo !empty($item->st) ? $item->st : 1; ?>
            </td>
            <td>
                <?php if (!empty($item->created_at)) {echo date(MEDIUM_DATE_FORMAT, $item->created_at->sec);}?>
            </td>
        </tr>
    <?php 
    endforeach; 
endif;
?>
</table>
<?php echo $pagination;?>
